<template>
  <div class="goods-list">
    <el-row style="margin-bottom:15px">
      <el-button type="primary" @click="nav('goodsAdd')">添加商品</el-button>
    </el-row>
    <el-table :data="list" stripe>
			<el-table-column type="selection"></el-table-column>
			<el-table-column prop="cover" label="封面">
				<template slot-scope="scope">
					<div>
						<img :src="scope.row.goodsCover" class="cover">
					</div>
				</template>
			</el-table-column>
      <el-table-column v-for="col in columns" :prop="col.value" :key="col.value" :label="col.label" show-overflow-tooltip></el-table-column>
      <el-table-column width="100px">
        <template slot-scope="scope">
          <div>
            <el-button type="primary" @click="nav('detail?id='+scope.row.id)">查看</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      columns:[
        {label:"订单编号",value:"orderNo"},
        {label:"收货人",value:"name"},
        {label:"手机",value:"phone"},
        {label:"收货地址",value:"address"},
				{label:"商品编号",value:"goodsId"},
				{label:"商品名称",value:"goodsName"},
				{label:"商品单价",value:"goodsPrice"},
				{label:"数量",value:"goodsNum"},
				{label:"规格",value:"goodsSize"},
			]
    };
  },
  created() {
    //let tab=[{name:'商品管理',path:'goodsList'}];
    //this.$store.commit('_setTab',tab);
    this.getData();
  },
  methods: {
    nav(path) {
      this.$router.push({
        path: path
      });
    },
    getData() {
      this.$api.orderList().then(res => {
        this.list = res.data;
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.goods-list{
	.cover{
		width: 0.8rem;
		height: 0.8rem;
		border-radius: 10px;
	}
}
</style>